// 搜索接口
const express = require("express");
const r = express.Router();
const pool = require("../mysql")

// 查询水果表下的所有数据
r.get("/list", (req, res, next) => {
    let sql = "select * from  fruits;";
    pool.query(sql, (err, result) => {
        if (err) {
            throw err
        }
        // 进行二序列化
        for (let i = 0; i < result.length; i++) {
            result[i].fruits = JSON.parse(result[i].fruits);
        }
        res.send({ code: 200, msg: "ok", data: result })
    })
})


module.exports = r
// 